﻿/****************************** Module Header ******************************\

Copyright (c) Gary Davidson

This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System.Xml.Linq;

namespace Savviety.ServiceManager.Facade.Criteria
{
    public class SimpleExpression : CriteriaElement
    {
        private readonly string property;
        private readonly string value;
        private readonly string expressionOperator;
         
        public SimpleExpression(XNamespace ns, string property, string value, string expressionOperator): base(ns)
        {
            this.property = property;
            this.value = value;
            this.expressionOperator = expressionOperator;
        }

        internal override XElement ToXElement()
        {
            return new XElement(Namespace + "Expression",
                                new XElement(Namespace + "SimpleExpression",
                                             new XElement(Namespace + "ValueExpressionLeft",
                                                          new XElement(Namespace + "Property", property)),
                                             new XElement(Namespace + "Operator", expressionOperator),
                                             new XElement(Namespace + "ValueExpressionRight",
                                                          new XElement(Namespace + "Value", value)))
                );
        }
    }
}